﻿using System;
using HttpApiGateway.Model;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
        /// <summary>
        /// 任务项
        /// </summary>
        internal class TaskItemController : HttpApiGateway.ApiController
        {
                private readonly IAutoTaskItemService _Service;
                public TaskItemController (IAutoTaskItemService service)
                {
                        this._Service = service;
                }
                /// <summary>
                /// 添加任务步骤
                /// </summary>
                /// <param name="item"></param>
                /// <returns></returns>
                public Guid Add (AddTaskItem item)
                {
                        return this._Service.Add (item);
                }
                /// <summary>
                /// 删除任务步骤
                /// </summary>
                /// <param name="id"></param>
                public void Delete ([NullValidate ("rpc.task.item.Id.null")] Guid id)
                {
                        this._Service.Delete (id);
                }
                /// <summary>
                /// 获取任务步骤
                /// </summary>
                /// <param name="id"></param>
                /// <returns></returns>
                public AutoTaskItem Get ([NullValidate ("rpc.task.item.Id.null")] Guid id)
                {
                        return this._Service.Get (id);
                }
                /// <summary>
                /// 获取任务步骤列表
                /// </summary>
                /// <param name="taskId"></param>
                /// <returns></returns>
                public TaskItem[] Gets ([NullValidate ("rpc.task.Id.null")] Guid taskId)
                {
                        return this._Service.Gets (taskId);
                }
                /// <summary>
                /// 设置任务步骤
                /// </summary>
                /// <param name="param"></param>
                public void Set (GuidParam<SetTaskItem> param)
                {
                        this._Service.Set (param.Id, param.Param);
                }
                /// <summary>
                /// 启用或禁用任务步骤
                /// </summary>
                /// <param name="set"></param>
                public void SetIsEnable (GuidParam<bool> set)
                {
                        this._Service.SetIsEnable (set.Id, set.Param);
                }
        }
}
